LOCAL = /usr/local
COPIER = cp -a

CC=g++

PLATFORM=WINDOWS_PLATFORM
#CPPFLAGS=-Iinclude/ -O3 -I/home/caffeine/PF/irrlicht-1.8/include -DLINUX_PLATFORM
DEFINES=

ifeq ($(OS),Windows_NT)
    PLATFORM=WINDOWS_PLATFORM
	OS=Windows
	DELETE = rm
else
    PLATFORM=LINUX_PLATFORM
	OS=Linux
	DELETE = rm
endif

CPPFLAGS=-Iinclude/ -g3 -I$(IRRLICHT_INCLUDE) $(DEFINES)
# -DNOT_USING_ICONV_LIB

LDFLAGS=-Lstatic
SOURCES=source/lampe.cpp \
source/io/CFileReader.cpp \
source/io/CFileWriter.cpp \
source/stream/CStringReader.cpp \
source/stream/CStringWriter.cpp \
source/stream/CMemoryStream.cpp \
source/stream/tcp/CTCPReader.cpp \
source/stream/tcp/CTCPWriter.cpp \
source/xml/CAttribute.cpp \
source/xml/CXMLFactoryEnvironment.cpp \
source/xml/CXmlNode.cpp \
source/xml/CXMLSaxList.cpp \
source/xml/CXMLSaxParser.cpp \
source/xml/FactorySimpeXML.cpp \
source/xml/Tags/include.cpp \
source/xml/Tags/style.cpp \
source/xml/Tags/style_item.cpp \
source/xml/Tags/using.cpp \
source/lib/socketlib.cpp \
source/lib/threadlib.cpp \
source/thread/CThread.cpp \
source/thread/CMutex.cpp \
source/thread/CMutexDefault.cpp \
source/thread/CMutexRecursive.cpp \
source/thread/CTaskThread.cpp \
source/network/CClient.cpp \
source/network/CServer.cpp \
source/network/tcp/CTCPClient.cpp \
source/network/tcp/CTCPServer.cpp \
source/MD5.cpp \
source/StringUtils.cpp

OBJECTS=$(SOURCES:.cpp=.o)

all:static_lampe

static_lampe: $(OBJECTS)
	@echo "Build liblampe.a"
	ar  rcs lib/$(OS)/liblampe.a $(OBJECTS)
	@ranlib lib/$(OS)/liblampe.a
	@echo "Done"
#	$(CC) $(LDFLAGS) $(OBJECTS) -o $@

%.d:%.cpp
	$(CC) $(CPPFLAGS) -MM -MF $@ $<

clean:
	$(DELETE) $(OBJECTS)

install:
	@echo "Copy headers devepol files and lib file..."
	@$(COPIER) -f -r include/lampe $(LOCAL)/include
	@chmod a+r -R $(LOCAL)/include/lampe
	
	@$(COPIER) -f lib/$(OS)/liblampe.a $(LOCAL)/lib
	@chmod a+r $(LOCAL)/lib/liblampe.a
	@echo "Done"
